<?php

namespace App\Http\Controllers\api;

use App\Http\Controllers\Controller;
use App\Repository\RepositoryInterface\ProductInterface;
use Illuminate\Http\Request;

class ProductController extends Controller
{
    //受保护模板
    protected $product;

    public function __construct(ProductInterface $product)
    {
        $this->product = $product;
    }

    /**
     * 商品预售
     * @return mixed
     */
    public function activeGoods(){
        return $this->product->activeGoods();
    }

    /**
     * 商品预售详情
     * @param Request $request
     * @return mixed
     */
    public function activeItem(Request $request){
        $id = $request->get('id');
        return $this->product->activeItem($id);
    }

    /**
     * 抢购商品预售
     * @param Request $request
     * @return mixed
     */
    public function deposit(Request $request){
        $params = $request->post();
        return $this->product->deposit($params);
    }

    /**
     * @param Request $request
     * 促销精品列表
     */
    public function productList(Request $request){
        return $this->product->productList();
    }

    /**
     * @param Request $request
     * @return mixed
     * 精品促销推荐方法(曼哈顿算法)
     */
    public function recommend(Request $request){
        $data=$request->get('product_id');
        $uid=$request->id;
        return $this->product->recommend($uid,$data);
    }

    /**
     * @param Request $request
     * @return false|string|void
     * 商品详情
     */
    public function detail(Request $request){
        $storeproduct_id=$request->get('storeproduct_id');
        return $this->product->productdetail($storeproduct_id);
    }

    /**
     * @param Request $request
     * 商品评论
     */
    public function remarklist(Request $request){
        $type=$request->get('show_type');
        $storeproduct_id=$request->get('storeproduct_id');

        return $this->product->productRemarklist($storeproduct_id,$type);
    }
}
